<!--
 * @Descripttion:
 * @version:
 * @Author: cxguo
 * @Date: 2020-07-06 21:37:52
 * @LastEditors: cxguo
 * @LastEditTime: 2020-07-21 20:51:06
-->
<template>
  <div class="glist">
    <el-tabs v-model="insideActiveName" type="card" @tab-click="handleTabClick">
      <el-tab-pane v-if="isShowTab('all')" label="全部商品" name="all">
        <All ref="all" v-bind="$attrs" />
      </el-tab-pane>
      <el-tab-pane v-if="isShowTab('minstock')" label="低库存商品" name="minstock">
        <MinStock ref="minstock" v-bind="$attrs" />
      </el-tab-pane>
      <el-tab-pane v-if="isShowTab('maxstock')" label="高库存商品" name="maxstock">
        <MaxStock ref="maxstock" v-bind="$attrs" />
      </el-tab-pane>
      <el-tab-pane v-if="isShowTab('hot')" label="热销商品" name="hot">
        <Hot ref="hot" v-bind="$attrs" />
      </el-tab-pane>
      <!-- <el-tab-pane v-if="isShowTab('package')" label="商品套餐" name="package">商品套餐</el-tab-pane> -->
    </el-tabs>
  </div>
</template>

<script>
import { oftenuse } from '@/libs/mixins'
import All from './all.vue'
import MinStock from './min-stock.vue'
import MaxStock from './max-stock.vue'
import Hot from './hot.vue'

export default {
  components: { All, MinStock, MaxStock, Hot },
  mixins: [oftenuse],
  props: {
    showTabNames: {
      type: Array,
      default: null
    }
  },
  data() {
    return {
      insideActiveName: 'all'
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    isShowTab(tabName) {
      const showTabs = this.showTabNames
      if (!showTabs) return true
      if (showTabs.indexOf(tabName) === -1) return false
      return true
    },
    resetData() {
      this.getCurrentVm().resetData()
    },
    setAllCheckboxRow(val) {
      this.getCurrentVm().setAllCheckboxRow(val)
    },
    getSelectData() {
      return this.getCurrentVm().getSelectData()
    },
    getCurrentVm() {
      const currentName = this.insideActiveName
      return this.$refs[currentName]
    },
    handleTabClick() {

    }
  }
}
</script>

<style lang="scss" scoped>
  .glist{
    /deep/.el-tabs__header{
      margin:0;
    }
  }
</style>

